package com.example.srm.constant;

/**
 * 申请表的状态
 */
public enum ProjectApplicationConstant {

    ON_APPLIACTION(0,"申报中"),

    FAIL_APPLICATION(1,"申报失败"),

    SUCCESS_APPLICATION(2,"申报成功");
    private int code;

    private String name;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    ProjectApplicationConstant(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static ProjectApplicationConstant getByName(String name){
        ProjectApplicationConstant[] values = values();
        for(ProjectApplicationConstant applicationStatus : values){
            if(name.equals(applicationStatus.getName())){
                return applicationStatus;
            }
        }
        return ProjectApplicationConstant.ON_APPLIACTION;
    }

    public static ProjectApplicationConstant getByCode(int code){
        ProjectApplicationConstant[] values = values();
        for(ProjectApplicationConstant applicationStatus : values){
            if(code == applicationStatus.getCode()){
                return applicationStatus;
            }
        }
        return ProjectApplicationConstant.ON_APPLIACTION;
    }
}
